home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
L' Effet Pommier 3
/
L'Effet Pommier - Volume 03.iso
/
Programmation
/
Gooey1.3.1
/
C Templates
/
Common.c
< prev
next >
Wrap
Text File
|
1995-01-29
|
8KB
|
278 lines
$$Message User Common, u:common$Prototype.name$.h
$$File u:common$Prototype.name$.h
/* common$Prototype.name$ Common */
/* $CopyRight$ */
/*
File name: common$Prototype.name$.h
Function: Common variables for program specific code.
History: $Date$ Original by $Author$
*/
/* ======================================================= */
/* ======================================================= */
/* NOTE : FormatRevision MUST be first in the record, and always a short */
typedef struct PrefsRec{ /* Preferences Record definition */
/* ALWAYS KEEP FormatRevision AS THE FIRST ELEMENT IN THIS RECORD */
short FormatRevision; /* FIRST ALWAYS, Change each time the format changes */
WindowLocRec theWindowLocRec; /* For saving window positions */
/* Add other preference variable definitions after this line */
}PrefsRec,*PrefsPRec,**PrefsHRec;
/* ======================================================= */
/* ======================================================= */
$$CloseFile
$$Message User Common, u:common$Prototype.name$.c
$$File u:common$Prototype.name$.c
/* common$Prototype.name$ Common */
/* $CopyRight$ */
/*
File name: common$Prototype.name$.c
Function: Common variables for program specific code.
History: $Date$ Original by $Author$
*/
#include "mmCommon$Prototype.name$.h" /* Common */
#include "common$Prototype.name$.h" /* Common */
/* ======================================================= */
/* ======================================================= */
#define PrefsCreator 'xxxx' /* Creator, this has to be the same as your App */
#define PrefsType 'Pref' /* Type, this has to match the type in your BNDL */
#define PrefsFileName "\p$Prototype.name$ Prefs" /* This is the name of your prefs file */
#define PrefsFormatRevision 1 /* Change each time the format changes */
/* ======================================================= */
/* Routine: U_InitPreferences */
/* Purpose: Set the default preferences */
void U_InitPreferences(void)
{
}
/* ======================================================= */
/* Routine: U_GetPrefParams */
/* Purpose: Get the preferences Parameters */
void U_GetPrefParams(OSType *PrefCreator,OSType *PrefType,Str255 *thePrefsFilename,long *PrefsRecSize,short *thePrefsFormatRevision)
{
*PrefCreator = PrefsCreator;
*PrefType = PrefsType;
PStrCopy((Str255 *)PrefsFileName,thePrefsFilename);
*PrefsRecSize = sizeof(PrefsRec);
*thePrefsFormatRevision = PrefsFormatRevision;
}
/* ======================================================= */
/* Routine: U_ReadPrefsPrivate */
/* Purpose: Read the prefs ourselves */
void U_ReadPrefsPrivate(short PrefsRefNum)
{
}
/* ======================================================= */
/* Routine: U_GetPreferences */
/* Purpose: Get the preferences from the Prefs record already read in */
void U_GetPreferences(Handle thePrefsH)
{
PrefsHRec thePrefs;
thePrefs = (PrefsHRec)thePrefsH;
theWindowLocRec = (*thePrefs)->theWindowLocRec; /* Get the window location data */
/* Use the form: xxxx = (*thePrefs)->xxxx; */
}
/* ======================================================= */
/* Routine: U_SetPreferences */
/* Purpose: Set new preferences, to be written out to the file */
void U_SetPreferences(Handle thePrefsH)
{
PrefsHRec thePrefs;
thePrefs = (PrefsHRec)thePrefsH;
(*thePrefs)->FormatRevision = PrefsFormatRevision; /* Version number */
(*thePrefs)->theWindowLocRec = theWindowLocRec; /* Save the window location data */
/* Use the form: (*thePrefs)->xxxx = xxxx; */
}
/* ======================================================= */
/* Routine: Close_The_Input_File */
/* Purpose: Close the input file */
void Close_The_Input_File(void)
{
OSErr ErrorCode;
ErrorCode = FSClose(Files.inputRefNum); /* Invalidate the refnum */
Files.inputRefNum = 0; /* Close the file */
}
/* ======================================================= */
/* Routine: Close_The_Output_File */
/* Purpose: Close the output file */
void Close_The_Output_File(void)
{
OSErr ErrorCode;
ErrorCode = FSClose(Files.outputRefNum); /* Invalidate the refnum */
Files.outputRefNum = 0; /* Close the file */
}
/* ======================================================= */
/* Routine: Open_The_File */
/* Purpose: Open the input file */
void Open_The_File(void)
{
short NumberOfTypes;
short theVolRefNum;
OSErr ErrorCode;
Files.typeList[0] = 'TEXT'; /* Open TEXT files */
Files.typeList[1] = 'text'; /* Open other files */
NumberOfTypes = 1; /* Only use first filetype in the list */
if (Do_The_Open_File(NumberOfTypes,&theVolRefNum,nil,nil))/* Try to open the file */
{
ErrorCode = FSOpen(Files.inputFileName, Files.Reply.vRefNum, &Files.inputRefNum);/* Open the file */
/* ADD in your code here to read the file */
Close_The_Input_File(); /* Now close this file */
}
}
/* ======================================================= */
/* Routine: Select_Volume */
/* Purpose: Select a volume */
void Select_Volume(void)
{
FSSpec theFile;
if (Has.NewStdFile) /* Do this if we have new Standard File available */
{
if (Do_The_Select_Volume(&theFile))
{
}
}
else
{
}
}
/* ======================================================= */
/* Routine: Save_The_File */
/* Purpose: Save the file */
void Save_The_File(void)
{
short theVolRefNum;
short theRefNum;
if (Do_The_Save_File(PrefsCreator, 'TEXT',(Str255 *)"\pSave as:",(Str255 *)"\pUntitled",/* Try to save the file */
&theVolRefNum,&theRefNum,nil))
{
/* ADD in your code here to save the file */
Close_The_Output_File(); /* Now close this file */
} /* End of IF */
}
/* ======================================================= */
/* Routine: Print_The_Data */
/* Purpose: Print the data */
void Print_The_Data(void)
{
GrafPtr ThePrintPort; /* Print port */
GrafPtr SavedPort; /* saved window port */
short Doing_Page; /* Current print page number */
short NumberOfCopies; /* Number of copies of each page */
short Count; /* Number of copies of each page */
Boolean Cancelled; /* User cancelled flag */
short NumberOfPages; /* Change this for the number of pages to do */
Str255 ThePageString; /* For showing the page number */
GetPort(&SavedPort); /* Get the current window port */
NumberOfPages = 2; /* CHANGE for your pages limit */
OpenThePrinter(&Cancelled); /* Ask about the next page */
if ((Printing.pPrPort != NIL) && (Printing.hPrint != NIL) && (!Cancelled))
{
ThePrintPort = (GrafPtr)Printing.pPrPort; /* Get the current window port */
SetPort(ThePrintPort); /* Point to the printer port */
TextFont(systemFont);
TextSize(12);
Doing_Page = 0;
do /* Do all the pages in our document */
{
InitCursor();
Doing_Page = Doing_Page + 1; /* Bump the page count */
PrOpenPage(Printing.pPrPort, nil); /* Open a new page */
SetPort(ThePrintPort);
/* ADD YOUR PRINTING CODE HERE, DRAW INTO THIS PORT */
MoveTo(10, 20);
DrawString((StringPtr)"\pPrinting from Gooey¬ code, page ");
NumToString(Doing_Page,ThePageString);
DrawString(ThePageString);
/* END OF ADD YOUR PRINTING CODE HERE */
PrClosePage(Printing.pPrPort); /* Print this page */
SetPort(SavedPort);
}
while (Doing_Page < NumberOfPages);
}
CloseThePrinter(); /* Close the printer */
SetPort(SavedPort);
InitCursor();
}
/* ======================================================= */
/* ======================================================= */
$$CloseFile